package org.free.server;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.free.data.Person;
import org.free.data.Tags;

import com.google.appengine.api.datastore.Key;

public class QueryQueue {
	/**
	 * contains the map of user and the last text to be sent to him
	 */
	static Map<Key, ArrayList<String>> query = new HashMap<Key, ArrayList<String>>();

	public static void addQuery(String tag, Object user, String ask) {
		List<Key> users = Tags.getUsers(tag);
		for (Key key : users) {
			ArrayList<String> currentList = query.get(key);
			if(currentList==null)
				currentList = new ArrayList<String>();
			
			currentList.add(ask);
			query.put(key, currentList);
		}

	}

	public static ArrayList<String> getQueries(Key userid) {
		if(query.get(userid)==null)
			return new ArrayList<String>();
		return query.get(userid); 
	}

	

}
